repo.or.cz
/
and.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
Adding some more judges, here and there.
[and.git]
/
Google Code Jam
/
2010
/
Qualification round
/
b-fair
/
b.rb
blob
69cc2f2e3e977df9b907077dccc60d61a5b34a4d
1
require 'rubygems'
2
3
t = readline.to_i
4
t.times do |kase|
5
print "Case #%d: " % (kase + 1)
6
a = readline.split.collect { |k| k.to_i }
7
a.shift
8
9
small = a.min
10
b = a.collect { |k| k - small }
11
g = b.first.to_i
12
1.upto(b.size - 1) do |i|
13
g = g.gcd(b[i])
14
end
15
puts ((g - small) % g + g) % g
16
end
17
18